home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3604 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  55 lines

  1. Newsgroups: comp.lang.c
  2. Path: gail.ripco.com!mambuhl
  3. From: mambuhl@ripco.com (Martin Ambuhl)
  4. Subject: Re: a dump question from 
  5. X-Nntp-Posting-Host: golden.ripco.com
  6. Message-ID: <DLz0o9.KIF@rci.ripco.com>
  7. Sender: usenet@rci.ripco.com (Net News Admin)
  8. Organization: Ripco Internet BBS Chicago
  9. Date: Tue, 30 Jan 1996 01:40:56 GMT
  10. X-Ident-Sender: mambuhl
  11.  
  12. jyli@climate.gsfc.nasa.gov (Jason Li)
  13. in <jyli-2801960040100001@li.gsfc.nasa.gov> asks:
  14.  
  15. >I have just started programming in C, still feel dizzy sometimes when
  16. >looking at cryptic C code.  Occasionally I come across code like this:
  17.  
  18. >for (iv=0; iv < specp->nlvars; iv++)
  19.  
  20. >what does this symbol "->" mean? I've looked all over my C books,  could
  21. >not find anything on it.
  22.  
  23. Your C books should have indices, in which you could look up
  24. ->  (Usually lexically before the alphas)
  25.   * or *
  26. component-selection operator
  27.  
  28. Component selection operators are used to access components of struct and
  29. union types.
  30.  
  31. Suppose you define a struct type:
  32.  
  33. typedef struct {
  34.     int a, b;
  35.     } INT_PAIR;
  36.  
  37. Now you can define a variable of this type or a pointer to such a variable:
  38.  
  39. INT_PAIR    pair, *ptr2pair;
  40.  
  41. If you make
  42.     ptr2pair = &pair;
  43.  
  44. then
  45.     pair.a
  46. and
  47.     ptr2pair->a
  48.  
  49. select the same member of the same object.
  50.  
  51.                                                                                                                    
  52. --
  53. * Martin Ambuhl       net: mambuhl@ripco.com
  54. * Chicago, IL (USA)    
  55.